package com.tongqin.distributed;

import com.tongqin.distributed.entity.User;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.util.concurrent.ListenableFuture;

/**
 * Hello world!
 */
public class SpringProducer {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/spring/applicationContext.xml");
        context.start();
        User user = context.getBean(User.class, "user");

        KafkaTemplate kafkaTemplate = context.getBean(KafkaTemplate.class, "kafkaTemplate");

        System.out.println(kafkaTemplate);

        ListenableFuture send = kafkaTemplate.send(new ProducerRecord<Integer, String>("test", "哈哈哈哈"));



        System.out.println("Hello World!"+user.getName());
    }
}
